﻿<Window x:Class="ColorDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ColorDialog" Height="222" Width="285" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterOwner">
    <Canvas>
        <Canvas.Resources>
            <DataTemplate x:Key="ColorItem">
                <DockPanel LastChildFill="True" Height="18">
                    <Rectangle Height="15" DockPanel.Dock="Left" Width="40" Stroke="Black">
                        <Rectangle.Fill>
                            <SolidColorBrush Color="{Binding Value, Mode=OneTime}"/>
                        </Rectangle.Fill>
                    </Rectangle>
                    <TextBlock Height="18" DockPanel.Dock="Left" Margin="3,2,5,0" Width="110"
                                       Foreground="Black" FontSize="11" Text="{Binding Key, Mode=OneTime}"/>
                </DockPanel>
            </DataTemplate>
        </Canvas.Resources>
        <ComboBox Name="cboPresets" Canvas.Left="12" Canvas.Top="12" Height="23" Width="241" IsSynchronizedWithCurrentItem="True" ItemTemplate="{DynamicResource ColorItem}" SelectedIndex="0"/>
        <Rectangle Canvas.Left="212" Canvas.Top="42" Height="98" Name="Preview" Width="39" Stroke="DimGray"/>
        <Slider Name="R" Canvas.Left="54" Canvas.Top="39" Height="22" Width="114" Maximum="255" SmallChange="1" 
                Value="{Binding Red,Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
        <TextBlock Canvas.Left="12" Canvas.Top="41" Height="19" Width="40" Text="Red:"/>
        <Slider Name="G" Canvas.Left="54" Canvas.Top="66" Height="22" Maximum="255" SmallChange="1" Width="114" 
                Value="{Binding Green,Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
        <TextBlock Canvas.Left="12" Canvas.Top="68" Height="19" Text="Green:" Width="40"/>
        <Slider Name="B" Canvas.Left="54" Canvas.Top="94" Height="22" Maximum="255" SmallChange="1" Width="114"
                Value="{Binding Blue,Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
        <TextBlock Canvas.Left="12" Canvas.Top="94" Height="19" Text="Blue:" Width="40"/>
        <Slider Name="A" Canvas.Left="54" Canvas.Top="119" Height="22" Maximum="255" SmallChange="1" Width="114"
                Value="{Binding Alpha,Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
        <TextBlock Canvas.Left="12" Canvas.Top="119" Height="19" Text="Alpha:" Width="40"/>
        <Button Canvas.Left="12" Canvas.Top="153" Height="23" Name="OK" Width="75" IsDefault="True">_OK</Button>  
        <Button Canvas.Left="93" Canvas.Top="153" Height="23" Width="75" IsCancel="True">_Cancel</Button>
        <TextBox Canvas.Left="174" Canvas.Top="154" Height="23" Name="Code" Width="79" Text="{Binding Value,Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Visibility="Hidden"/>
        <TextBlock Canvas.Left="174" Canvas.Top="42" Height="19" Width="30" Name="RedValue"/>
        <TextBlock Canvas.Left="174" Canvas.Top="69" Height="19" Width="30" Name="GreenValue"/>
        <TextBlock Canvas.Left="174" Canvas.Top="95" Height="19" Width="30" Name="BlueValue"/>
        <TextBlock Canvas.Left="174" Canvas.Top="120" Height="19" Width="30" Name="AlphaValue"/>
    </Canvas>
</Window>
